package com.iretailer.report.mapper;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.iretailer.report.base.SuperMapper;
import com.iretailer.report.model.BusinessTimeCompany;
import com.iretailer.report.model.BusinessTimeMall;
import com.iretailer.report.model.BusinessTimes;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @Auther: xjw
 * @Date: 2019/1/21 11:25
 * @Description:
 */
public interface BusinessTimeMapper extends SuperMapper<BusinessTimes> {

    List<BusinessTimes> selectAllOrderTimeTypeName();

    List<BusinessTimes> selectByMallId(@Param("mallId") String mallId);

    List<BusinessTimes> selectByMallIds(@Param("mallIds") List<String> mallIds);

    /**
     * 根据 userId 查询出 user 下的 business
     */
    List<BusinessTimes> selectByUserId(@Param("userId") String userId);

    /**
     * 根据 businessTimeId 查询 主要用于删除 businessTimes的时候是否还有关联
     */
    List<String> selectMallIdsById(@Param("businesstimeId") String businessTimeId);

    Integer deleteBusinessTimeByIds(@Param("ids") List<Long> ids);

    Integer deleteBusinessTimeMallByBusinessTimeIdAndMallId(@Param("businesstimeId") String businessTimeId, @Param("mallId") String mallId);

    /**
     * 删除 businessTimeId 的所有关联
     */
    Integer deleteBusinessTimeMallsByBusinessTimeId(@Param("businesstimeId") String businessTimeId);

    /**
     * 向 t_businesstimes_malls 中插入所有关联
     */
    Integer insertBusinessTimeMalls(@Param("businesstimeId") String businessTimeId, @Param("mallIds") List<String> mallIds);

    IPage<BusinessTimeCompany> selectPageBusinessTimeCompanyName(Page page, @Param("ew") QueryWrapper queryWrapper);

}
